

include ../common.mk

TARGET:= tsf

MDL_LIST :=  dvb format portable utility expat

CLEAN_LIST := $(addsuffix _c,$(MDL_LIST))

TEST_LIST :=$(addsuffix _t,$(MDL_LIST))

BUILD_LIST:=$(addsuffix _b,$(MDL_LIST))

ARC_LIST := $(addsuffix .a,$(MDL_LIST))

INCLUDE := $(addprefix -I../, $(MDL_LIST))

$(TARGET):  main.o $(ARC_LIST)
	g++ $(FLAG) -o $@ $^ 

$(ARC_LIST):$(BUILD_LIST)

$(BUILD_LIST):%:
	@cd ../$(subst _b,,$@)/ && make 

$(CLEAN_LIST):%:
	@cd ../$(subst _c,,$@)/ && make clean

$(TEST_LIST):%:
	@cd ../$(subst _t,,$@)/ && make test

main.o: main.c
	g++ $(FLAG) $(INCLUDE) -c -o main.o main.c


test:$(TEST_LIST)
	@echo TARGET=$(TARGET)
	@echo MDL_LIST=$(MDL_LIST)
	@echo ARC_LIST=$(ARC_LIST)
	@echo TEST_LIST=$(TEST_LIST)
	@echo CLEAN_LIST=$(CLEAN_LIST)
	@echo INCLUDE=$(INCLUDE)
	@echo FLAG=$(FLAG)

clean:$(CLEAN_LIST) 
	-rm -f $(TARGET) $(ARC_LIST) main.o
	
